<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>微服务架构中的服务暴露流程</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        
        .card-hover {
            transition: all 0.3s ease;
            border: 2px solid transparent;
        }
        
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 40px rgba(0,0,0,0.1);
            border-color: #667eea;
        }
        
        .step-number {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            width: 40px;
            height: 40px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 50%;
            font-weight: bold;
            flex-shrink: 0;
        }
        
        .section-title {
            position: relative;
            padding-left: 20px;
        }
        
        .section-title::before {
            content: '';
            position: absolute;
            left: 0;
            top: 50%;
            transform: translateY(-50%);
            width: 4px;
            height: 24px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border-radius: 2px;
        }
        
        .feature-icon {
            background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }
        
        .mermaid {
            background: white;
            padding: 2rem;
            border-radius: 12px;
            box-shadow: 0 10px 30px rgba(0,0,0,0.1);
        }
        
        @keyframes fadeInUp {
            from {
                opacity: 0;
                transform: translateY(30px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
        
        .animate-fadeInUp {
            animation: fadeInUp 0.6s ease-out;
        }
        
        .highlight-box {
            background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
            border-left: 4px solid #ff6b6b;
            padding: 1rem 1.5rem;
            border-radius: 8px;
            margin: 1rem 0;
        }
        
        .tech-tag {
            background: rgba(102, 126, 234, 0.1);
            color: #667eea;
            padding: 0.25rem 0.75rem;
            border-radius: 20px;
            font-size: 0.875rem;
            display: inline-block;
            margin: 0.25rem;
            transition: all 0.3s ease;
        }
        
        .tech-tag:hover {
            background: #667eea;
            color: white;
            transform: scale(1.05);
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <div class="hero-gradient text-white py-20">
        <div class="container mx-auto px-6">
            <div class="max-w-4xl mx-auto text-center animate-fadeInUp">
                <h1 class="text-5xl md:text-6xl font-bold mb-6" style="font-family: 'Noto Serif SC', serif;">
                    微服务架构中的服务暴露流程
                </h1>
                <p class="text-xl md:text-2xl opacity-90 leading-relaxed">
                    深入解析分布式系统中服务发现与治理的核心机制
                </p>
                <div class="mt-8 flex justify-center space-x-4">
                    <span class="tech-tag bg-white bg-opacity-20 text-white">
                        <i class="fas fa-network-wired mr-2"></i>微服务
                    </span>
                    <span class="tech-tag bg-white bg-opacity-20 text-white">
                        <i class="fas fa-cloud mr-2"></i>分布式系统
                    </span>
                    <span class="tech-tag bg-white bg-opacity-20 text-white">
                        <i class="fas fa-cogs mr-2"></i>服务治理
                    </span>
                </div>
            </div>
        </div>
    </div>

    <!-- Introduction -->
    <div class="container mx-auto px-6 py-12">
        <div class="max-w-4xl mx-auto">
            <div class="bg-white rounded-2xl shadow-xl p-8 animate-fadeInUp">
                <p class="text-lg leading-relaxed text-gray-700 indent-8">
                    服务暴露的流程在分布式系统中至关重要，特别是在微服务架构中。服务暴露的核心在于使服务可以被其他服务或客户端发现和访问。以下是一个典型的服务暴露流程，通常涉及以下几个步骤：
                </p>
            </div>
        </div>
    </div>

    <!-- Service Flow Visualization -->
    <div class="container mx-auto px-6 py-8">
        <div class="max-w-6xl mx-auto">
            <h2 class="text-3xl font-bold text-center mb-8 text-gray-800">服务暴露流程架构图</h2>
            <div class="mermaid">
                graph TB
                    A[服务定义] --> B[服务实现]
                    B --> C[服务注册]
                    C --> D[服务暴露]
                    D --> E[服务发现]
                    E --> F[服务调用]
                    F --> G[服务治理]
                    G --> H[安全控制]
                    H --> I[版本管理]
                    I --> J[故障恢复]
                    
                    style A fill:#667eea,stroke:#fff,stroke-width:2px,color:#fff
                    style B fill:#764ba2,stroke:#fff,stroke-width:2px,color:#fff
                    style C fill:#f093fb,stroke:#fff,stroke-width:2px,color:#fff
                    style D fill:#f5576c,stroke:#fff,stroke-width:2px,color:#fff
                    style E fill:#4facfe,stroke:#fff,stroke-width:2px,color:#fff
                    style F fill:#00f2fe,stroke:#fff,stroke-width:2px,color:#fff
                    style G fill:#fa709a,stroke:#fff,stroke-width:2px,color:#fff
                    style H fill:#fee140,stroke:#fff,stroke-width:2px,color:#fff
                    style I fill:#30cfd0,stroke:#fff,stroke-width:2px,color:#fff
                    style J fill:#a8edea,stroke:#fff,stroke-width:2px,color:#fff
            </div>
        </div>
    </div>

    <!-- Main Content -->
    <div class="container mx-auto px-6 py-12">
        <div class="max-w-6xl mx-auto">
            <div class="grid grid-cols-1 md:grid-cols-2 gap-8">
                
                <!-- 1. 服务定义 -->
                <div class="card-hover bg-white rounded-xl shadow-lg p-6">
                    <div class="flex items-start mb-4">
                        <div class="step-number">1</div>
                        <h3 class="text-2xl font-bold ml-4 section-title">服务定义</h3>
                    </div>
                    <div class="ml-14">
                        <div class="mb-4">
                            <h4 class="font-semibold text-lg mb-2 flex items-center">
                                <i class="fas fa-file-contract feature-icon mr-2"></i>
                                接口定义
                            </h4>
                            <p class="text-gray-600 leading-relaxed">
                                首先，服务需要定义一个明确的接口，通常是一个服务契约（Service Contract），这可以是 Java 的接口或 RESTful API 定义。接口包括方法名、输入参数、返回值和可能的异常等。
                            </p>
                        </div>
                        <div>
                            <h4 class="font-semibold text-lg mb-2 flex items-center">
                                <i class="fas fa-tags feature-icon mr-2"></i>
                                元数据声明
                            </h4>
                            <p class="text-gray-600 leading-relaxed">
                                服务还需要声明一些元数据，如服务名称、版本号、依赖关系等，以便在注册和调用时使用。
                            </p>
                        </div>
                    </div>
                </div>

                <!-- 2. 服务实现 -->
                <div class="card-hover bg-white rounded-xl shadow-lg p-6">
                    <div class="flex items-start mb-4">
                        <div class="step-number">2</div>
                        <h3 class="text-2xl font-bold ml-4 section-title">服务实现</h3>
                    </div>
                    <div class="ml-14">
                        <div class="mb-4">
                            <h4 class="font-semibold text-lg mb-2 flex items-center">
                                <i class="fas fa-code feature-icon mr-2"></i>
                                实现类编写
                            </h4>
                            <p class="text-gray-600 leading-relaxed">
                                开发者根据定义的接口编写服务的具体实现类，包含业务逻辑。这个实现类将实际提供服务的功能。
                            </p>
                        </div>
                        <div>
                            <h4 class="font-semibold text-lg mb-2 flex items-center">
                                <i class="fas fa-sliders-h feature-icon mr-2"></i>
                                配置管理
                            </h4>
                            <p class="text-gray-600 leading-relaxed">
                                服务实现需要配置一些管理信息，如运行时的线程池大小、超时时间等，以优化性能。
                            </p>
                        </div>
                    </div>
                </div>

                <!-- 3. 服务注册 -->
                <div class="card-hover bg-white rounded-xl shadow-lg p-6">
                    <div class="flex items-start mb-4">
                        <div class="step-number">3</div>
                        <h3 class="text-2xl font-bold ml-4 section-title">服务注册</h3>
                    </div>
                    <div class="ml-14">
                        <div class="mb-4">
                            <h4 class="font-semibold text-lg mb-2 flex items-center">
                                <i class="fas fa-server feature-icon mr-2"></i>
                                服务注册中心
                            </h4>
                            <p class="text-gray-600 leading-relaxed">
                                服务启动时，将自身的地址和元数据注册到一个服务注册中心，如 Eureka、Consul 或 Zookeeper。这一步是服务暴露的关键，注册中心会维护一个动态的服务实例列表。
                            </p>
                        </div>
                        <div>
                            <h4 class="font-semibold text-lg mb-2 flex items-center">
                                <i class="fas fa-heartbeat feature-icon mr-2"></i>
                                健康检查
                            </h4>
                            <p class="text-gray-600 leading-relaxed">
                                服务注册中心通常会定期进行健康检查，确保注册的服务实例是可用的。不可用的实例会从注册中心剔除。
                            </p>
                        </div>
                    </div>
                </div>

                <!-- 4. 服务暴露 -->
                <div class="card-hover bg-white rounded-xl shadow-lg p-6">
                    <div class="flex items-start mb-4">
                        <div class="step-number">4</div>
                        <h3 class="text-2xl font-bold ml-4 section-title">服务暴露</h3>
                    </div>
                    <div class="ml-14">
                        <div class="mb-4">
                            <h4 class="font-semibold text-lg mb-2 flex items-center">
                                <i class="fas fa-plug feature-icon mr-2"></i>
                                暴露端点
                            </h4>
                            <p class="text-gray-600 leading-relaxed">
                                服务通过绑定特定的端口和协议（如 HTTP、gRPC）来暴露端点。这些端点是外部调用者访问服务的入口。
                            </p>
                        </div>
                        <div>
                            <h4 class="font-semibold text-lg mb-2 flex items-center">
                                <i class="fas fa-balance-scale feature-icon mr-2"></i>
                                负载均衡器
                            </h4>
                            <p class="text-gray-600 leading-relaxed">
                                如果有多个服务实例，服务注册中心会提供负载均衡功能，分发请求到不同的实例。服务也可以通过网关或反向代理来实现负载均衡。
                            </p>
                        </div>
                    